import Vue from 'vue';
import VueRouter from "vue-router"
Vue.use(VueRouter)
const router = new VueRouter({
    mode: "history",
    routes: [
        {
            path: "/index",
            redirect: "/",
        }, {
            path: "/",
            name: "index",
            component: () => import("@/views/index.vue"),

        },
        {
            path: "/show",
            name: "show",
            component: () => import("@/views/show.vue"),

        }
        , {
            path: "/types",
            name: "types",
            component: () => import("@/views/types.vue"),
        }, {
            path: "/contactUs",
            name: "contactUs",
            component: () => import("@/views/contactUs.vue"),
        }, {
            path: "/news",
            name: "news",
            component: () => import("@/views/news.vue"),
        }, {
            path: "/aboutUs",
            name: "aboutUs",
            component: () => import("@/views/aboutUs.vue"),
        }, {
            path: "/guide",
            name: "guide",
            component: () => import("@/views/guide.vue"),
        }, {
            path: "/afterSale",
            name: "afterSale",
            component: () => import("@/views/afterSale.vue"),
        }, {
            path: "/newdetail",
            name: "newdetail",
            component: () => import("@/views/newDetail.vue"),
        }, {
            path: "/feadback",
            name: "feadback",
            component: () => import("@/views/feadback.vue"),
        }, {
            path: "/Job",
            name: "Job",
            component: () => import("@/views/getJob"),
            children: [{
                path: "/jobIndex",
                name: "jobIndex",
                component: () => import("@/views/getJob/jobIndex.vue"),
                meta: {
                    title: '首页'
                }
            }, {
                path: "/jobList",
                name: "jobList",
                component: () => import("@/views/getJob/jobList.vue"),
                meta: {
                    title: '招聘职位'
                }
            }, {
                path: "/jobInfo",
                name: "jobInfo",
                component: () => import("@/views/getJob/jobInfo.vue"),
                meta: {
                    title: '职业详情'
                }
            }, {
                path: "/getjob",
                name: "getjob",
                component: () => import("@/views/getJob/getJob.vue"),
                meta: {
                    title: '投递简历'
                }
            }]
        },
        {
            path: '*',
            redirect: '/404'
        },
        {
            path: "/404",
            name: "notfound",
            component: () => import("@/views/notfound.vue"),
        }
    ],
    scrollBehavior(to, from, savedPosition) {
        if (to.path == from.path) {
            return
        }
        if (savedPosition) {
            return savedPosition
        } else {
            return { x: 0, y: 0 }
        }
    }
})
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function (location) {
    return originalPush.call(this, location).catch(err => err)
};


export default router